cmake_minimum_required(VERSION 3.16)

# 项目名称
project(thdetect)

# 设置C标准
#set(CMAKE_C_STANDARD 11)
#set(CMAKE_C_STANDARD_REQUIRED ON)

# 添加源文件
set(SOURCES
    src/main.c
    src/modbus.c
    src/mqtt_client.c
    src/daemon.c
)

# 添加头文件目录
include_directories(
    ${CMAKE_SOURCE_DIR}/thirdpart/mosquitto/mosquitto-2.0.14/include
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)

# 生成可执行文件
add_executable(${PROJECT_NAME} ${SOURCES})

# 链接mosquitto库
target_link_libraries(${PROJECT_NAME} PRIVATE libmosquitto)

# 设置RPATH相关属性
set_target_properties(${PROJECT_NAME} PROPERTIES
    INSTALL_RPATH "$ORIGIN/../lib"
    BUILD_WITH_INSTALL_RPATH TRUE
    SKIP_BUILD_RPATH FALSE
)

# 安装目标
install(TARGETS ${PROJECT_NAME}
    RUNTIME DESTINATION bin
)